<html>
<head><meta charset="utf-8"><title>type aliases and implied bounds · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html">type aliases and implied bounds</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136284834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284834">(Oct 22 2018 at 18:21)</a>:</h4>
<p>So <span class="user-mention" data-user-id="131694">@scalexm</span> briefly...</p>



<a name="136284840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284840">(Oct 22 2018 at 18:22)</a>:</h4>
<p>today, when we see <code>type Foo = Bar</code>, during <em>type lowering</em> we convert it into <code>Bar</code></p>



<a name="136284885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284885">(Oct 22 2018 at 18:22)</a>:</h4>
<p>this means that if you have e.g. <code>type Foo&lt;X&gt; = Vec&lt;X&gt;</code>, and you have <code>fn func(x: Foo&lt;u32&gt;)</code>, we never see <code>Foo&lt;u32&gt;</code> as a <code>Ty&lt;'tcx&gt;</code> at all</p>



<a name="136284896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284896">(Oct 22 2018 at 18:22)</a>:</h4>
<p>ok</p>



<a name="136284901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284901">(Oct 22 2018 at 18:22)</a>:</h4>
<p>this means that we never really considered very much what bounds are declared on the type alias</p>



<a name="136284910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284910">(Oct 22 2018 at 18:23)</a>:</h4>
<p>so e.g. <code>struct HashSet&lt;K: Hash&gt;</code>, <code>type Foo&lt;K&gt; = HashSet&lt;K&gt;</code>, does not get an error</p>



<a name="136284919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284919">(Oct 22 2018 at 18:23)</a>:</h4>
<p>yes I'm familiar with that</p>



<a name="136284921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284921">(Oct 22 2018 at 18:23)</a>:</h4>
<p>as you can imagine, it is hard to change this without breaking code — though perhaps not as much as I feared</p>



<a name="136284929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284929">(Oct 22 2018 at 18:23)</a>:</h4>
<p>we've been investigating various parameters of this</p>



<a name="136284939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284939">(Oct 22 2018 at 18:23)</a>:</h4>
<p>there was some hope of making some things hard errors in Rust 2018 to lay groundwork</p>



<a name="136284948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284948">(Oct 22 2018 at 18:24)</a>:</h4>
<p>in particular extra bounds</p>



<a name="136284991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284991">(Oct 22 2018 at 18:24)</a>:</h4>
<p>i.e., you could "ret-con" <code>type Foo = Bar</code> as having an implied where clause like <code>WellFormed(Bar)</code></p>



<a name="136284997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284997">(Oct 22 2018 at 18:24)</a>:</h4>
<p>but if there are <em>extra</em> bounds like <code>type Foo&lt;T: Hash&gt; = Vec&lt;T&gt;</code></p>



<a name="136284999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136284999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136284999">(Oct 22 2018 at 18:24)</a>:</h4>
<p>and we started enforcing those</p>



<a name="136285001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285001">(Oct 22 2018 at 18:24)</a>:</h4>
<p>it would break existing code</p>



<a name="136285035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285035">(Oct 22 2018 at 18:25)</a>:</h4>
<p>so we wanted to error if you have a bound B <em>unless</em> <code>WellFormed(Bar) =&gt; Implemented(B)</code></p>



<a name="136285047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285047">(Oct 22 2018 at 18:25)</a>:</h4>
<p>I'm however feeling like there's not time to do this change right</p>



<a name="136285060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285060">(Oct 22 2018 at 18:25)</a>:</h4>
<p>I guess I don't know if I have a question for you specifically</p>



<a name="136285141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285141">(Oct 22 2018 at 18:26)</a>:</h4>
<p>mmh ok we want to error if you have a non-existing bound, and we would also want to error if the type alias is not well-formed, e.g. in your <code>type Foo&lt;K&gt; = HashSet&lt;K&gt;</code> we would now complain that <code>K: Hash</code> is missing?</p>



<a name="136285157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285157">(Oct 22 2018 at 18:27)</a>:</h4>
<p>well</p>



<a name="136285162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285162">(Oct 22 2018 at 18:27)</a>:</h4>
<p>if we could go back to pre-1.0 days =)</p>



<a name="136285169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285169">(Oct 22 2018 at 18:27)</a>:</h4>
<p>I think I would make type aliases be implemented literally as a kind of "custom projection"</p>



<a name="136285178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285178">(Oct 22 2018 at 18:27)</a>:</h4>
<p>e.g., <code>type Foo&lt;P*&gt; = X</code> would be</p>



<a name="136285224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285224">(Oct 22 2018 at 18:28)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Out</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Out</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">X</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="136285240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285240">(Oct 22 2018 at 18:28)</a>:</h4>
<p>and each reference to <code>Foo&lt;A*&gt;</code> would be <code>&lt;() as Foo&lt;A*&gt;&gt;::Out</code></p>



<a name="136285243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285243">(Oct 22 2018 at 18:28)</a>:</h4>
<p><em>however</em></p>



<a name="136285251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285251">(Oct 22 2018 at 18:28)</a>:</h4>
<p>as I said, that would break a lot of crates, probably not an option without either an edition or a long migration period,</p>



<a name="136285253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285253">(Oct 22 2018 at 18:28)</a>:</h4>
<blockquote>
<p>mmh ok we want to error if you have a non-existing bound, and we would also want to error if the type alias is not well-formed, e.g. in your <code>type Foo&lt;K&gt; = HashSet&lt;K&gt;</code> we would now complain that <code>K: Hash</code> is missing?</p>
</blockquote>
<p>precisely because of this</p>



<a name="136285265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285265">(Oct 22 2018 at 18:29)</a>:</h4>
<p>yes ok so we just want to deal with extra bounds right now</p>



<a name="136285273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285273">(Oct 22 2018 at 18:29)</a>:</h4>
<p>I think the hope was</p>



<a name="136285275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285275">(Oct 22 2018 at 18:29)</a>:</h4>
<p>if we dealt with that</p>



<a name="136285279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285279">(Oct 22 2018 at 18:29)</a>:</h4>
<p>we could (in Rust <em>2018</em>)</p>



<a name="136285280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285280">(Oct 22 2018 at 18:29)</a>:</h4>
<p>translate to this:</p>



<a name="136285286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285286">(Oct 22 2018 at 18:29)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Out</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">P</span><span class="o">*&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">WF</span><span class="p">(</span><span class="n">X</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Out</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">X</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="136285299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285299">(Oct 22 2018 at 18:30)</a>:</h4>
<p>which would be roughly equivalent to today</p>



<a name="136285340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285340">(Oct 22 2018 at 18:30)</a>:</h4>
<p>but principled :)</p>



<a name="136285355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285355">(Oct 22 2018 at 18:30)</a>:</h4>
<p>(this would also almost work in 2015, but that extra bounds would not be enforced)</p>



<a name="136285378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285378">(Oct 22 2018 at 18:30)</a>:</h4>
<p>ok I see</p>



<a name="136285423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285423">(Oct 22 2018 at 18:31)</a>:</h4>
<p>like I said, I'm not sure what I really wanted to ask you</p>



<a name="136285432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285432">(Oct 22 2018 at 18:31)</a>:</h4>
<p>for extra bounds, I guess we would just to change a bit the translation</p>



<a name="136285433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285433">(Oct 22 2018 at 18:31)</a>:</h4>
<p>maybe just to bring up up to date :)</p>



<a name="136285485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285485">(Oct 22 2018 at 18:32)</a>:</h4>
<blockquote>
<p>for extra bounds, I guess we would just to change a bit the translation</p>
</blockquote>
<p>what do you mean exactly?</p>



<a name="136285499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285499">(Oct 22 2018 at 18:32)</a>:</h4>
<p>mmh no I was thinking about adding those extra bounds on the projection type but that would not work</p>



<a name="136285621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285621">(Oct 22 2018 at 18:35)</a>:</h4>
<p>I mean we could "retcon" the current behavior by saying</p>



<a name="136285627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285627">(Oct 22 2018 at 18:35)</a>:</h4>
<p>"explicit bounds are ignored"</p>



<a name="136285629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285629">(Oct 22 2018 at 18:35)</a>:</h4>
<p>:P</p>



<a name="136285702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136285702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136285702">(Oct 22 2018 at 18:36)</a>:</h4>
<p>anyway, I'm feeling like this should not be a blocker though — but it's tricky, of course, because it'd be nice to do this right and not have to wait a long time. I guess I would just like to think we can push that through as a "bug fix" sort of change</p>



<a name="136287420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287420">(Oct 22 2018 at 19:04)</a>:</h4>
<blockquote>
<p>"retcon" the current behavior</p>
</blockquote>
<div class="codehilite"><pre><span></span><span class="k">type</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nb">Into</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="o">=</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
</pre></div>


<div class="codehilite"><pre><span></span>warning: where clauses are not enforced in type aliases
 --&gt; src/lib.rs:3:5
  |
3 |     T: Into&lt;i32&gt;,
  |     ^^^^^^^^^^^^
  |
  = note: #[warn(type_alias_bounds)] on by default
  = help: the clause will not be checked when the type alias is used, and should be removed
</pre></div>



<a name="136287458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287458">(Oct 22 2018 at 19:05)</a>:</h4>
<p>yes well</p>



<a name="136287460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287460">(Oct 22 2018 at 19:05)</a>:</h4>
<p>first step, remove that lint ;)</p>



<a name="136287473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287473">(Oct 22 2018 at 19:05)</a>:</h4>
<p>although basically it evaluates to what I am proposing</p>



<a name="136287475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287475">(Oct 22 2018 at 19:05)</a>:</h4>
<p>I mean, isn't that what you want to retcon <em>to</em>?</p>



<a name="136287538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287538">(Oct 22 2018 at 19:06)</a>:</h4>
<p>to a certain extent, yes, indeed. This is why we added the lint in the first place, basically, because I expected we'd do some sort of retcon that rationalized the behavior</p>



<a name="136287549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287549">(Oct 22 2018 at 19:06)</a>:</h4>
<p>I .. kinda still think that should be the way to go, just for project mgmt reasons if nothing else, at least to start... <a href="https://github.com/rust-lang/rust/issues/55222#issuecomment-431937764" target="_blank" title="https://github.com/rust-lang/rust/issues/55222#issuecomment-431937764">I left a comment here on #55222</a></p>



<a name="136287677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287677">(Oct 22 2018 at 19:09)</a>:</h4>
<p>From the outside, it feels reasonable to go from that warning today to some bounds being applied, even in a regular version bump; no need for edition.</p>



<a name="136287691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/type%20aliases%20and%20implied%20bounds/near/136287691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/type.20aliases.20and.20implied.20bounds.html#136287691">(Oct 22 2018 at 19:09)</a>:</h4>
<p>And continue warning for any specific types of bounds that might not be applied.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>